#ifndef __CP15_H__
#define __CP15_H__

#include "basictype.h"

#define CR3_DOMAIN_COUNT 16

#define CR3_DOMAIN_CLIENT_INDEX 0
#define CR3_DOMAIN_MANAGER_INDEX 1

enum{
    CR3_DOMAIN_ATTR_NOACCESS=0,
    CR3_DOMAIN_ATTR_CLIENT,
    CR3_DOMAIN_ATTR_RESERVED,
    CR3_DOMAIN_ATTR_MANAGER,
    CR3_DOMAIN_ATTR_COUNT,
};

extern UINT32 CP15_ReadDeviceID(void);
extern UINT32 CP15_ReadCacheInfo(void);

extern void CP15_EnableMMU(void);
extern void CP15_DisableMMU(void);
extern void CP15_EnableAlignCheck(void);
extern void CP15_DisableAlignCheck(void);
extern void CP15_EnableDCache(void);
extern void CP15_DisableDCache(void);
extern void CP15_SetBigEndian(void);
extern void CP15_SetLittleEndian(void);
extern void CP15_SetSBit(void);
extern void CP15_ClearSBit(void);
extern void CP15_SetRBit(void);
extern void CP15_ClearRBit(void);
extern void CP15_EnableICache(void);
extern void CP15_DisableICache(void);
extern void CP15_SetVBit(void);
extern void CP15_ClearVBit(void);
extern void CP15_SetRRBit(void);
extern void CP15_ClearRRBit(void);
extern void CP15_SetFastBusMode(void);
extern void CP15_SetAsyncBusMode(void);

extern void CP15_SetTTBBase(UINT32 addr);

extern void CP15_SetDomain(UINT32 domain);
extern UINT32 CP15_GetDomain(void);

extern void CP15_InvalidateIDCache(void);
extern void CP15_InvalidateICache(void);
extern void CP15_InvalidateDCache(void);
extern void CP15_InvalidICacheMVA(UINT32 mva);
extern void CP15_PrefetchICacheMVA(UINT32 mva);
extern void CP15_InvalidDCacheMVA(UINT32 mva);
extern void CP15_CleanSingleDCacheEntryMVA(UINT32 entry);
extern void CP15_CleanAndInvalidateDCacheEntryMVA(UINT32 entry);
extern void CP15_CleanSingleDCacheEntryIdx(UINT32 index);
extern void CP15_CleanAndInvalidateDCacheEntryIdx(UINT32 index);
extern void CP15_DrainWriteBuffer(void);
extern void CP15_WaitForInterrupt(void);

extern void CP15_InvalidateTLB(void);
extern void CP15_InvalidateTLB_I(void);
extern void CP15_InvalidateTLB_I_Entry(UINT32 mva);
extern void CP15_InvalidateTLB_D(void);
extern void CP15_InvalidateTLB_D_Entry(UINT32 mva);
extern UINT32 CP15_ReadDCacheLockdownBase(void);
extern UINT32 CP15_ReadICacheLockdownBase(void);
extern void CP15_WriteDCacheVictimAndBase(UINT32 victimOrBase);
extern void CP15_WriteICacheVictimAndBase(UINT32 victimOrBase);
extern UINT32 CP15_ReadTLBLockDown_D(void);
extern UINT32 CP15_ReadTLBLockDown_I(void);
extern void CP15_WriteTLBLockDown_I(UINT32 mva);
extern void CP15_WriteTLBLockDown_D(UINT32 mva);
extern UINT32 CP15_ReadProcessId(void);
extern void CP15_SetProcessId(UINT32 id);
#endif